package hk.mrtomato.control;

import hk.mrtomato.dto.MruserDTO;
import hk.mrtomato.help.ActionForward;
import hk.mrtomato.model.MrBoardService;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class MrRegiAction implements Action {

	@Override
	public ActionForward execute(HttpServletRequest request,
			HttpServletResponse response) {
		
		MrBoardService manager = MrBoardService.getInstance();
		
		String id = request.getParameter("id");
		String password = request.getParameter("password");
		String name = request.getParameter("name");
		String address = request.getParameter("address");
		
		MruserDTO mrDto = new MruserDTO(id,password,3,name,address);
		boolean isC = manager.insertUser(mrDto);		
		
		ActionForward forward = new ActionForward();
		if(isC){
			forward.setUrl("regi");
		}else{
			forward.setUrl("error");
		}		
		return forward;
	}
} 
